package com.idanchuang.support.etcache.support.jetcache;

import com.alicp.jetcache.external.ExternalCacheBuilder;
import com.idanchuang.support.etcache.EtCacheManager;

/**
 * @author yjy
 */
public class EtCacheJetCacheBuilder<T extends ExternalCacheBuilder<T>> extends ExternalCacheBuilder<T> {
    public static class EtCacheJetCacheBuilderImpl extends EtCacheJetCacheBuilder<EtCacheJetCacheBuilderImpl> {
    }

    public static EtCacheJetCacheBuilderImpl createEtCacheBuilder() {
        return new EtCacheJetCacheBuilderImpl();
    }

    protected EtCacheJetCacheBuilder() {
        buildFunc((c) -> new EtCacheJetCache((EtCacheExternalCacheConfig) c));
    }


    @Override
    public EtCacheExternalCacheConfig getConfig() {
        if (config == null) {
            config = new EtCacheExternalCacheConfig();
        }
        return (EtCacheExternalCacheConfig) config;
    }

    public T manager(EtCacheManager manager){
        getConfig().setManager(manager);
        return self();
    }
}
